{ Siberian Olympiad. 2 stage.
  Problemset: http://agul-problems1.googlecode.com/svn/trunk/2010-2011/wso/stage2/wso_2stage.pdf
  Problem 2.
  Points: 100
}
{$APPTYPE CONSOLE}
uses SysUtils;
const big=2000000000;
var s,t,r,k:array[0..2] of int64; n,g:int64; i,a,b,c,ths:longint;
function max(a,b:int64):int64;
begin
if a>b then result:=a else result:=b;
end;
procedure swap(var a,b:int64);
var i:int64;
begin
i:=a;
a:=b;
b:=i;
end;
procedure value(a:int64; var get:array of int64);
begin
get[1]:=get[0];
get[0]:=a;
end;
function gcd(a,b:int64):int64;
begin
a:=abs(a);
b:=abs(b);
if a<b then swap(a,b);
while b<>0 do begin
  a:=a mod b;
  if a<b then swap(a,b);
end;
result:=a;
end;
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
readln(n);
for i:=1 to n do begin
  readln(a,b,c);
  g:=gcd(a,b);
  if (c mod g<>0) then writeln('666 666') else begin
    a:=a div g;
    b:=b div g;
    c:=c div g;
    r[1]:=abs(a);
    s[1]:=1;
    t[1]:=0;
    k[1]:=1;
    r[0]:=abs(b);
    s[0]:=0;
    t[0]:=1;
    k[0]:=1;
    while r[0]<>1 do begin
      value(r[1] div r[0],k);
      value(-s[0]*k[0]+s[1],s);
      value(-t[0]*k[0]+t[1],t);
      value(r[1] mod r[0],r);
    end;
    s[0]:=s[0]*c;
    t[0]:=t[0]*c;
    if a<0 then s[0]:=s[0]*-1;
    if b<0 then t[0]:=t[0]*-1;
    a:=a*g;
    b:=b*g;
    while (big<abs(s[0])) or (big<abs(t[0])) do begin
      ths:=((max(abs(s[0]),abs(t[0]))-big) div (max(abs(b),abs(a)) div g)) + 1;
      dec(s[0],((b div g)*ths));
      inc(t[0],((a div g)*ths));
    end;
    writeln(s[0],' ',t[0]);
  end;
end;
end.

